/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.max.cjs.dao.hibernate;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.transform.Transformers;
import org.max.cjs.dao.interfac.IScheduleDao;
import org.max.cjs.dao.util.GenericEntityDao;
import org.max.cjs.model.Schedule;

/**
 *
 * @author user
 */
public class ScheduleDao extends GenericEntityDao<Schedule, Long> implements IScheduleDao {

    @Override
    public List listHQL(String hql, int lazyChargeOption, Object object) throws Exception {
        List list = new ArrayList();
        if (lazyChargeOption == 1) {
            List<Date> listParam = (List<Date>) object;
            list = getSessionFactory().getCurrentSession()
                    .createQuery(hql)
                    .setParameter("start", listParam.get(0))
                    .setParameter("end", listParam.get(1))
                    .setResultTransformer(Transformers.aliasToBean(Schedule.class))
                    .list();
        }
        return list;
    }

}
